package com.zyh.homework;

public class Test6 {
    public static void main(String[] args) {
        /*
        1.创建一个测试类,
	    2.定义两个方法分别统计出5位数的回文数个数和7位数的回文数个数
	    3.在主方法中分别调用者两个方法 计算出相差的个数
         */
        int count5 = getCount5();
        int count7 = getCount7();
        int n;
        if (count5>count7){
            n=count5-count7;
        }
        else {
            n=count7-count5;
        }
        System.out.println("相差的个数为："+n);
    }

    public static int getCount5() {
        int count = 0;
        for (int i = 10000; i < 100000; i++) {
            int g, s, b, q, w;
            g = i / 1 % 10;
            s = i / 10 % 10;
            b = i / 100 % 10;
            q = i / 1000 % 10;
            w = i / 10000 % 10;
            if (g == w && s == q) {
//                System.out.print(i + "\t");
                count++;
            }
        }
        System.out.println("count = " + count);
        return count;

    }

    public static int getCount7() {
        int count = 0;
        for (int i = 1000000; i < 10000000; i++) {
            int g, s, b, q, w, sw, bw;
            g = i / 1 % 10;
            s = i / 10 % 10;
            b = i / 100 % 10;
            q = i / 1000 % 10;
            w = i / 10000 % 10;
            sw = i / 100000 % 10;
            bw = i / 1000000 % 10;
            if (g == bw && s == sw && b == w) {
//                System.out.print(i + "\t");
                count++;
            }
        }
        System.out.println("count = " + count);
        return count;
    }

}
